package com.dingjiaxiong.xiongbi_backend.config;


import com.dingjiaxiong.xiongbi_backend.api.OpenAIChatClient;
import com.dingjiaxiong.xiongbi_backend.api.OpenAIChatProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(OpenAIChatProperties.class)
public class OpenAIChatAutoConfiguration {

    private final OpenAIChatProperties properties;

    public OpenAIChatAutoConfiguration(OpenAIChatProperties properties) {
        this.properties = properties;
    }

    @Bean
    @ConditionalOnMissingBean
    public OpenAIChatClient openAIChatClient() {
        return new OpenAIChatClient(properties.getApiKey());
    }
}